<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>demo sc - 系统工作台</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/vue.min.js"></script>
    <link rel="stylesheet" href="css/frame.css">
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                url: "/api/user/info",
                success: function (result) {
                    console.log(arguments);
                    $("#welcome").text(result + "，欢迎登录系统！")
                },
                error: function (xhr) {
                    if (xhr.status == "401") {
                        alert(xhr.statusText + ": " + xhr.responseText);
                        location.href = "login.html";
                    }
                }
            });

            $("#logout").bind("click", () => {
                $.ajax({
                    url: "/api/user/logout",
                    success: () => {
                        location.href = "login.html";
                    }
                });
            });

        });
    </script>
</head>

<body>
    <header class="header">
        <nav>
            <div id="welcome" class="welcome"></div>
            <div class="logout">
                <a id="logout">注销</a>
            </div>
        </nav>
    </header>
</body>

</html>